
/**
 * Checkbox组件
 * @class Checkbox
 * @extends Basic
 *
 * @param [checked] 是否选中
 * @param value value值
 * @param [text] 显示的文案
 * @param [disabled] 是否禁用
 * @param {function} [onClick(v)] 点击事件
 *
 * 示例:
 *
 *     @example
 *     <Checkbox id="11" value="复选框1"  text="自定义内容" />
 */
var Checkbox = React.createClass({
    getDefaultProps:function(){
        return{
            id: "",
            value: "",
            dmbind:""
        }
    },
    handler: function (e) {
        var _input = e.target || e.srcElement,
            _checked = _input.checked;
        this.props.onClick && this.props.onClick(_checked);
    },
    render: function () {
        var checked = this.props.value ? true : false;
        var className = this.props.className;
        var text = this.props.text ? this.props.text : '';
        return (
            <label className={className ? "ucs-checkbox " + className : "ucs-checkbox"}>
                <input type="checkbox" checked={checked} id={this.props.id} value={this.props.value} className="ucs-checkbox-input" dmbind={this.props.dmbind}
                       onClick={this.handler.bind(this)}/>
                <span className="ucs-checkbox-text">{text}</span>
            </label>
        )
    }
});

module.exports = Checkbox;


